/**
 * Copyright (c) 2014, 2017, Oracle and/or its affiliates.
 * The Universal Permissive License (UPL), Version 1.0
 */
"use strict";
define(["ojs/ojcore","knockout","ojs/ojmodel"],function(a,g){a.ib=function(){};o_("KnockoutUtils",a.ib,a);a.ib.oZ="oj._internalObj";a.ib.uk="oj._underUpdate";a.ib.bA="oj.collectionUpdating";a.ib.K_="oj.collectionSubscription";a.ib.R_="oj.collectionUpdatingFunc";a.ib.map=function(b,c,d){function e(c){return function(d){f[a.ib.uk]||b.set(c,d)}}var f,h,k,l;if(b instanceof a.l){h=Array(b.vf());f=d?g.observableArray(h):h;a.ib.Sda(f,b);if(d)for(h=0;h<b.cd.length;h++)k=b.cd[h],f()[k]=a.ib.map(b.pq(k,null,
!0,!1),c);else for(h=0;h<b.cd.length;h++)k=b.cd[h],f[k]=a.ib.map(b.pq(k,null,!0,!1),c);h=function(c){var d;try{if(!f[a.ib.uk]){f[a.ib.bA]=!0;for(d=0;d<c.length;d++){var e=c[d].index,g=a.ib.Rc(c[d].value),h=c[d].status;"added"===h?e>=b.length-1?b.add(g):b.add(g,{at:e}):"deleted"===h&&b.iw(g,e)}b.comparator&&(f[a.ib.uk]=!0,f.sort(function(c,d){return a.ib.Y4(c,d,b.comparator,b,this)}),f[a.ib.uk]=!1)}}catch(k){throw k;}finally{f[a.ib.bA]=!1}};d&&f.subscribe&&(f[a.ib.R_]=h,f[a.ib.K_]=f.subscribe(h,null,
"arrayChange"));d=function(b,c,d){var e;try{!f[a.ib.bA]&&c instanceof a.l&&(f[a.ib.uk]=!0,e=d.index,f.splice(e,1))}catch(g){throw g;}finally{f[a.ib.uk]=!1}};h=function(b,d,e){var g,h;try{if(!f[a.ib.bA]&&d instanceof a.l&&(f[a.ib.uk]=!0,g=d.fAa(b),void 0!==g&&-1<g))if(h=a.ib.map(b,c),e.fillIn){for(var k=Array.isArray(f)?f.length:f().length;k<g;k++)f.splice(k,0,a.ib.map(d.pq(k,null,!0,!1),c));f.splice(g,1,h)}else f.splice(g,0,h)}catch(l){throw l;}finally{f[a.ib.uk]=!1}};k=function(b){try{!f[a.ib.bA]&&
b instanceof a.l&&(f[a.ib.uk]=!0,g.isObservable(f)?(f[a.ib.K_]&&f[a.ib.K_].dispose(),f.removeAll(),f[a.ib.R_]&&f.subscribe(f[a.ib.R_],null,"arrayChange")):f=[])}catch(c){throw c;}finally{f[a.ib.uk]=!1}};l=function(c){try{!f[a.ib.bA]&&c instanceof a.l&&(f[a.ib.uk]=!0,f.sort(function(d,e){return a.ib.Y4(d,e,b.comparator,c,this)}))}catch(d){throw d;}finally{f[a.ib.uk]=!1}};b.Zp(a.ka.O.ADD,h,void 0,void 0,!0);b.Zp(a.ka.O.REMOVE,d,void 0,void 0,!0);b.Zp(a.ka.O.RESET,k,void 0,void 0,!0);b.Zp(a.ka.O.SORT,
l,void 0,void 0,!0)}else{if(void 0===b)return;f={};d=b.attributes;h=null;for(h in d)d.hasOwnProperty(h)&&(k=g.observable(b.get(h)),f[h]=k,l=e(h),l.sNa=h,k.subscribe&&k.subscribe(l));d=function(b){var c,d;try{for(d in f[a.ib.uk]=!0,c=b.eY(),c)if(c.hasOwnProperty(d))f[d](b.get(d))}catch(e){throw e;}finally{f[a.ib.uk]=!1}};b.Zp(a.ka.O.CHANGE,d,void 0,void 0,!0);a.ib.Sda(f,b);c&&c(f)}return f};o_("KnockoutUtils.map",a.ib.map,a);a.ib.Rc=function(b){return b instanceof a.C?b:b.hasOwnProperty(a.ib.oZ)?b[a.ib.oZ]:
b};a.ib.Y4=function(b,c,d,e,f){return a.l.n1(a.ib.Rc(b),a.ib.Rc(c),d,e,f)};a.ib.Sda=function(b,c){Object.defineProperty(b,a.ib.oZ,{value:c,enumerable:!1})}});